///******************************************************************************
// * Copyright (C) 2011 ShenZhen ComTop Information Technology Co.,Ltd
// * All Rights Reserved.
// * 锟斤拷锟斤拷锟轿拷锟斤拷诳锟斤拷锟斤拷湛锟斤拷锟斤拷锟斤拷啤锟轿达拷锟斤拷锟斤拷锟剿撅拷锟绞斤拷锟斤拷锟酵拷猓拷锟斤拷锟斤拷魏胃锟斤拷恕锟斤拷锟斤拷宀伙拷锟绞癸拷谩锟�
// * 锟斤拷锟狡★拷锟睫改或发诧拷锟斤拷锟斤拷锟�
// *****************************************************************************/
//
//package com.code.common.utils;
//
//import java.io.IOException;
//import java.io.UnsupportedEncodingException;
//import java.security.InvalidKeyException;
//import java.security.NoSuchAlgorithmException;
//import java.security.spec.InvalidKeySpecException;
//
//import javax.crypto.BadPaddingException;
//import javax.crypto.Cipher;
//import javax.crypto.IllegalBlockSizeException;
//import javax.crypto.NoSuchPaddingException;
//import javax.crypto.SecretKey;
//import javax.crypto.SecretKeyFactory;
//import javax.crypto.spec.DESKeySpec;
//
//import com.bea.common.security.utils.encoders.BASE64Decoder;
//import com.bea.common.security.utils.encoders.BASE64Encoder;
//
//
///**
// * 锟斤拷锟杰斤拷锟杰癸拷锟斤拷锟斤拷
// * 
// * @author 锟铰达拷锟斤拷
// * @since jdk1.5
// * @version 2011-6-28 锟铰达拷锟斤拷 锟铰斤拷
// */
//public class Crypt {
//    
//    /**
//     * 锟斤拷锟斤拷锟皆�
//     * 
//     * @return key key
//     * @throws NoSuchAlgorithmException NoSuchAlgorithmException
//     * @throws InvalidKeyException InvalidKeyException
//     * @throws InvalidKeySpecException InvalidKeySpecException
//     */
//    public static SecretKey getKey() throws NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException {
//        String s = "g8TlgLEc6oqZxdwGe6pDiKB8Y";
//        char[] ss = s.toCharArray();
//        String sss = "";
//        for (int i = 0; i < ss.length; i = i + 2) {
//            sss = sss + ss[i];
//        }
//        SecretKeyFactory kf = SecretKeyFactory.getInstance("DES");
//        DESKeySpec ks = new DESKeySpec(sss.substring(0, 8).getBytes());
//        SecretKey kd = kf.generateSecret(ks);
//        return kd;
//    }
//    
//    /**
//     * 锟斤拷取锟斤拷锟杰猴拷锟斤拷址锟�
//     * 
//     * @param key 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟皆匡拷锟斤拷址锟�
//     * @param input 锟斤拷要锟斤拷锟杰碉拷锟街凤拷
//     * @return 锟斤拷锟截硷拷锟杰猴拷锟斤拷址锟�
//     */
//    public String getEncryptedString(String key, String input) {
//        String strBase64 = "";
//        try {
//            Cipher objCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
//            objCipher.init(Cipher.ENCRYPT_MODE, getKey());
//            byte[] byteInputBytes = input.getBytes("UTF8");
//            byte[] byteOutputBytes = objCipher.doFinal(byteInputBytes);
//            BASE64Encoder objEncoder = new BASE64Encoder();
//            strBase64 = objEncoder.encodeBuffer(byteOutputBytes);
//        } catch (NoSuchAlgorithmException e) {
//            strBase64 = e.getMessage();
//        } catch (NoSuchPaddingException e) {
//            strBase64 = e.getMessage();
//        } catch (InvalidKeyException e) {
//            strBase64 = e.getMessage();
//        } catch (InvalidKeySpecException e) {
//            strBase64 = e.getMessage();
//        } catch (IllegalBlockSizeException e) {
//            strBase64 = e.getMessage();
//        } catch (BadPaddingException e) {
//            strBase64 = e.getMessage();
//        } catch (UnsupportedEncodingException e) {
//            strBase64 = e.getMessage();
//        }
//        return strBase64;
//    }
//    
//    /**
//     * 锟斤拷取锟斤拷锟杰猴拷锟斤拷址锟�
//     * 
//     * @param key 锟斤拷锟斤拷锟斤拷锟斤拷锟皆匡拷锟斤拷址锟�
//     * @param input 锟斤拷要锟斤拷锟杰碉拷锟街凤拷
//     * @return 锟斤拷锟杰猴拷锟斤拷址锟�
//     */
//    public String getDecryptedString(String key, String input) {
//        String strResult = null;
//        try {
//            Cipher objCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
//            objCipher.init(Cipher.DECRYPT_MODE, getKey());
//            BASE64Decoder objDecoder = new BASE64Decoder();
//            byte[] byteRaw = objDecoder.decodeBuffer(input);
//            byte[] byteStringBytes = objCipher.doFinal(byteRaw);
//            strResult = new String(byteStringBytes, "UTF8");
//        } catch (IOException e) {
//            strResult = e.getMessage();
//        } catch (NoSuchAlgorithmException e) {
//            strResult = e.getMessage();
//        } catch (NoSuchPaddingException e) {
//            strResult = e.getMessage();
//        } catch (InvalidKeyException e) {
//            strResult = e.getMessage();
//        } catch (InvalidKeySpecException e) {
//            strResult = e.getMessage();
//        } catch (IllegalBlockSizeException e) {
//            strResult = e.getMessage();
//        } catch (BadPaddingException e) {
//            strResult = e.getMessage();
//        }
//        return strResult;
//    }
//    
//}